package com.lisn.roomlib;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;

import com.lisn.roomlib.FileInfo.FileInfo;

import java.util.List;

/**
 * @author : lishan
 * @e-mail : cnlishan@163.com
 * @date : 2020/8/14 4:39 PM
 * @desc :
 */
public class FileViewModel extends AndroidViewModel {

    private final FileRepository fileRepository;
    private final LiveData<List<FileInfo>> allFileInfos;

    public FileViewModel(@NonNull Application application) {
        super(application);
        fileRepository = new FileRepository();
        allFileInfos = fileRepository.getAllFileInfos();
    }

    LiveData<List<FileInfo>> getAllFileInfos() {
        return allFileInfos;
    }

    void save(FileInfo fileInfo) {
        fileRepository.save(fileInfo);
    }
}
